#ifndef _CENEMYGENERATOR_H_
#define _CENEMYGENERATOR_H_

#include "CEnemy.h"
#include "CEnemyParams.h"
#include "CEnemyWave.h"
#include "cocos2d.h"
#include "Box2D/Box2D.h"
#include "CEnemyType1.h"
#include "CEnemyType2.h"
#include "CEnemyType3.h"

/**
 * This class generates enemies of different types and sizes.
 */
class CEnemyGenerator :
	public cocos2d::CCNode
{
public:
	CEnemyGenerator();
	void init(cocos2d::CCArray* pEnemies, cocos2d::CCSpriteBatchNode* pSpriteSheet, b2World* pWorld=NULL);
	void startNextWave();

private:
	/**
	 * The sprite sheet is created and released by the MainLayer.
	 */
	cocos2d::CCSpriteBatchNode* 		_pSpriteSheet;

	/**
	 * The enemies array is created and released by the MainLayer.
	 */
	cocos2d::CCArray*	_pEnemies;

	/**
	 * Difficulty is updated with consecutive enemy waves.
	 */
	float								_difficulty;

	/**
	 * Holds information about enemy count and probability values
	 * for different enemy types and sizes.
	 */
	CEnemyWave							_currentWave;

	/**
	 * This Box2D world is set in the MainLayer and passed to the EnemyGenerator
	 */
	b2World* 							_pWorld;

	void generate(float dt);
	void generateNewEnemy();
	CEnemy* createEnemy(CEnemyParams enemyParams);
	void setSizeProbability();
	void setTypeProbability();
	CEnemyParams::EEnemySize getEnemySize();
	CEnemyParams::EEnemyType getEnemyType();
};

#endif //_CENEMYGENERATOR_H_
